package com.adam.management.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @projectName: adam-management-system
 * @description:
 * @author: Adam
 * @create: 2019-11-13 20:33
 **/

@Controller
@RequestMapping("/login")
public class LoginController {

    private static Logger logger = LoggerFactory.getLogger(LoginController.class);

    @RequestMapping(value = "/page",method = RequestMethod.GET)
    public String login(){
        return "login";
    }

    @RequestMapping(value = "/do",method = RequestMethod.POST)
    public String doLogin(){
        return  "redirect:index";
    }

    @GetMapping("/signout/success")
    public String signout() {
        return "退出成功，请重新登录";
    }

    @GetMapping("/auth/admin")
    @PreAuthorize("hasAuthority('admin')")
    @ResponseBody
    public String authenticationTest() {
        return "您拥有admin权限，可以查看";
    }
}
